#ifndef _ALTING_H
#define _ALTING_H

#include <pthread.h>
#include <csp_shared_types.h>
#include <ProcessComposition.h>



using namespace std;

class ChannelManager;

class Alting
{
	public:
		Alting(ProcessComposition *p);
		~Alting();
		void Setup(csp_channel_t *list, int n_guards);

		ProcessComposition* AquireWrite(int idx);
		ProcessComposition* PriSelect();
	private:

	//	channel_link_t* BeginDisabling(Channel *chosen);

		ProcessComposition *altingProcess;
		csp_channel_t *guards;
		int n_guards;
		int i;

		ChannelManager *channelManager;
		
		pthread_mutex_t mutex;
		pthread_cond_t state_cv;

		int state;
		bool pendingWrites;

		bool processIsDisabling;
		int highestPriority;


};

#endif
